﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.Reporting.WebForms;
using Ewts.Code;

namespace Ewts.RDLC
{
    public partial class OurstorSale : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int outStorID = 0;
                if (Request["outStorID"] != null && Request["outStorID"].ToString().Trim() != "")
                {
                    outStorID = int.Parse(Request["outStorID"].ToString().Trim());
                    //GetReportMultipleDataSourceFile
                }

                BindData(outStorID);
            }
        }

        protected void BindData(int outStorID)
        {
            List<ReportParameter> parameterList = new List<ReportParameter>();
            DataSet ds1 = new DataLib.BLL.BarCode().GetList("id = '" + outStorID + "'");
            DataLib.Model.OutStorage outModel = new DataLib.BLL.OutStorage().GetModel(outStorID);

            //参数设置
            if (outModel != null)
            {
                parameterList.Add(new ReportParameter("OutStorNum", outModel.outStorageNo));
                parameterList.Add(new ReportParameter("InDepart", outModel.inDepart));
                parameterList.Add(new ReportParameter("OutDepart", outModel.OutDepart));
                parameterList.Add(new ReportParameter("OutDate", ((DateTime)outModel.outStorageDate).ToLongDateString().ToString()));
            }

            //为DataSet1绑定数据集
            ReportDataSource rds = new ReportDataSource("DataSet1", ds1.Tables[0]);//注意这里的name和报表中的一致
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(rds);
            new RDLCPrinter().FillRow(ds1.Tables[0], 3, 25, 25);//为列表添加空行
            ReportViewer1.LocalReport.SetParameters(parameterList);
            ReportViewer1.LocalReport.Refresh();
        }
    }
}